import tkinter as tk
from tkinter import filedialog
from transcribe import transcribe_audio


def select_audio_file():
    # 选择音频文件，支持 wav, mp3, flac 和 m4a 格式
    file_path = filedialog.askopenfilename(filetypes=[("Audio Files", "*.wav;*.mp3;*.flac;*.m4a")])
    if file_path:
        transcribe_audio(file_path, text_box)


def create_ui():
    # 创建主窗口
    root = tk.Tk()
    root.title("AudioTranscriber")

    global text_box

    # 创建文本框
    text_box = tk.Text(root, wrap=tk.WORD, width=80, height=20)
    text_box.pack(padx=10, pady=10)

    # 创建选择文件按钮
    select_button = tk.Button(root, text="选择音频文件", command=select_audio_file)
    select_button.pack(pady=10)

    # 运行主循环
    root.mainloop()
